# 图片操作
# @Author ZhangGJ
# @Date 2021/11/21 23:40

import cv2.cv2 as cv2

flower = '../images/flower.jpg'


def read_image():
    # image = cv2.imread('../images/flower.jpg', 0)
    image = cv2.imread(flower)

    # 不能自动生成save文件
    cv2.imwrite("../images/save/flower.jpg", image)

    print(image)
    cv2.imshow("Flower", image)
    cv2.waitKey(3000)
    cv2.destroyAllWindows()


def image_attribute():
    image_color = cv2.imread(flower)
    print("获取彩色图像的属性: ")
    print("shape = ", image_color.shape)  # 打印彩色图像的(像素行数， 像素列数， 通道数)
    print("size = ", image_color.size)  # 打印彩色图像包含的像素个数
    print("dtype = ", image_color.dtype)  # 打印彩色图像的数据类型

    image_gray = cv2.imread(flower, 0)
    print("shape = ", image_gray.shape)  # 打印灰度图像的（像素行数，像素列数）
    print("size = ", image_gray.size)  # 打印灰度图像包含的像素个数
    print("dtype = ", image_gray.dtype)  # 打印灰度图像的数据类型


if __name__ == '__main__':
    image_attribute()
